package com.chencong.source;

import com.chencong.bean.UserOrderCount;
import com.chencong.env.FlinkTableEnv;
import com.chencong.udf.SourceFromMysqlFunc;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author chencong
 * @Description    自定义读取mysql主程序
 * @Date 8:25 下午 2021/8/16
 * @Param
 **/
public class Source_UDF {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment streamTableEnvironment = FlinkTableEnv.getStreamTableEnvironment();
        streamTableEnvironment.setParallelism(1);

        DataStreamSource<UserOrderCount> userOrderCountDataStreamSource = streamTableEnvironment.addSource(new SourceFromMysqlFunc());

        userOrderCountDataStreamSource.print();

        streamTableEnvironment.execute("source from mysql");
    }
}
